package com.xyy.saas.payment.adpater.xydLoan.core.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;

/**
 * 小雨点放款状态
 */
public enum XydPayStatusEnum {

    ESIGN_SUBMIT("ESIGN_SUBMIT", "提款签约提交"),
    LOAN_CANCEL("LOAN_CANCEL", "提款取消（终态）"),
    DECLINE("DECLINE", "提款拒绝（终态）"),
    PROCCESSING("PROCCESSING", "提交放款"),
    FAILED("FAILED", "放款取消（终态）"),
    SUCCESSED("SUCCESSED", "放款成功（终态）");

    private String code;
    private String desc;

    private static Map<String, XydPayStatusEnum> code2Enum;

    public static Map<String, String> statusConverter = new HashMap<>();

    static {
        code2Enum = Arrays.asList(values()).stream().collect(Collectors.toMap(XydPayStatusEnum::getCode, UnaryOperator.identity()));
        statusConverter.put(XydPayStatusEnum.ESIGN_SUBMIT.getCode(),"ESIGN_SUBMIT");
        statusConverter.put(XydPayStatusEnum.LOAN_CANCEL.getCode(),"LOAN_CANCEL");
        statusConverter.put(XydPayStatusEnum.DECLINE.getCode(),"DECLINE");
        statusConverter.put(XydPayStatusEnum.PROCCESSING.getCode(),"PROCCESSING");
        statusConverter.put(XydPayStatusEnum.FAILED.getCode(),"FAILED");
        statusConverter.put(XydPayStatusEnum.SUCCESSED.getCode(),"SUCCESSED");
    }

    XydPayStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String convertPayStatus(String code) {
        return statusConverter.get(code);
    }
    public static XydPayStatusEnum getEnum(String code){
        return code2Enum.get(code);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

}
